#include "lib.h"

#include "rlshare.h"
#include "amerguts.h"
#include "amrlbet.h"
#include "getrand.h"

AmericanRouletteGuts::AmericanRouletteGuts()
{
}

uint8 
AmericanRouletteGuts::spin()
{
	static uint8 spots[38] = {14,2 ,20,29,31,0 ,10,28,17,24,36,19,
							  26,37,13,32,8 ,30,12,1 ,27,7 ,35,18,
							  5 ,33,15,23,9 ,11,21,4 ,16,34,3 ,22,
							  25,6};

	uint8 numRands = (uint8) (3*((getrand()/(DWORD)2048) % 8)); 

	for(uint8 i = 0; i<numRands; i++)
	{
		getrand();
	}

	DWORD tempResult = getrand();
	bool8 found = false;
	while(!found)
	{
		if((tempResult)<(DWORD)4294967214)
		{
			found = true;
		}
		else
		{
			tempResult = getrand();
		}
	}

	return (37-spots[(uint8)((getrand() % 76)/2)]);
}

bool8
AmericanRouletteGuts::validateBet(uint8 wagerID)
{
	return AmericanRouletteBet::isValidBet(wagerID);
}


RouletteBet *
AmericanRouletteGuts::newBet(uint8 wagerID, int32 amount)
{
	return new AmericanRouletteBet(wagerID, amount);
}
